﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class site : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.User.Identity.IsAuthenticated)
        {
            var messageSource = (SqlDataSource)LoginView1.FindControl("messageSource");
            messageSource.SelectCommand = string.Format(@"
SELECT COUNT(*) AS [count] 
FROM Message 
WHERE (receiver = '{0}') AND (isRead = 'false')"
            , Membership.GetUser().ProviderUserKey);
        }
    }
}
